home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2000 February / MacFormat 87.iso / Shareware Plus / Utilities / uCalendar2.0.4(PPC) f / Samples / GetSchedule next >
Encoding:
Text File  |  1999-03-31  |  1.9 KB  |  61 lines  |  [TEXT/ToyS]

  1. global uStart, uDays
  2. set uStart to (current date)
  3. set uDays to 7
  4.  
  5. on DateString(dateobj)
  6.     set str to every word of (dateobj as text)
  7.     set dstr to ""
  8.     repeat with i from 1 to the (number of items in str) - 3
  9.         if (i is not 1) then set dstr to dstr & " "
  10.         set dstr to dstr & item i of str
  11.     end repeat
  12.     return dstr
  13. end DateString
  14.  
  15. with timeout of 3600 seconds
  16.     display dialog ¬
  17.         "Please input starting date" default answer ¬
  18.         "1999/1/1" buttons {"Cancel", "Ok", "Today"} default button 2 with icon 1
  19.     set uAns to result
  20.     if (button returned of uAns) is "Cancel" then return
  21.     if (button returned of uAns) is "Today" then
  22.         set uStart to (current date)
  23.         set uStart to uStart - (time of uStart)
  24.     else
  25.         set uStart to date (text returned of uAns as text)
  26.     end if
  27.     
  28.     display dialog ¬
  29.         "How long days do you need?" default answer (uDays as text) ¬
  30.         buttons {"Cancel", "Ok"} default button 2 with icon 1
  31.     set uAns to result
  32.     if (button returned of uAns) is "Cancel" then return
  33.     set uDays to (text returned of uAns as number)
  34.     
  35.     set uFile to new file with prompt "Output:" default name my DateString(uStart)
  36.     set fh to open for access uFile with write permission
  37.     try
  38.         repeat uDays times
  39.             tell application "uCalendar"
  40.                 -- if do not open the calendar, get  schedule from the front calendar
  41.                 --open {alias "Mac:1999 Calendar"}
  42.                 set uMemo to GetMemo on uStart
  43.             end tell
  44.             if (length of uMemo is not 0) then
  45.                 write "--------------------------" & return to fh
  46.                 set uText to my DateString(uStart) & return & "--" & return
  47.                 repeat with i from 1 to the number of items in uMemo
  48.                     set uText to uText & item i of uMemo & return
  49.                 end repeat
  50.                 write (uText) to fh
  51.                 display dialog uText buttons {"More"} default button 1 with icon 1
  52.             end if
  53.             set uStart to uStart + days
  54.         end repeat
  55.         close access fh
  56.         display dialog "Complete" buttons {"OK"} default button 1 with icon 1
  57.     on error errMsg
  58.         close access fh
  59.         error errMsg
  60.     end try
  61. end timeout